package cn.iocoder.yudao.module.promotion.dal.mysql.promotion;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.promotion.dal.dataobject.promotion.PromotionDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.promotion.controller.admin.promotion.vo.*;

/**
 * 促销 Mapper
 *
 * @author 徐煜东
 */
@Mapper
public interface PromotionMapper extends BaseMapperX<PromotionDO> {

    default PageResult<PromotionDO> selectPage(PromotionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PromotionDO>()
                .eqIfPresent(PromotionDO::getProductId, reqVO.getProductId())
                .eqIfPresent(PromotionDO::getPromoTitle, reqVO.getPromoTitle())
                .eqIfPresent(PromotionDO::getPromoDescription, reqVO.getPromoDescription())
                .eqIfPresent(PromotionDO::getIsActive, reqVO.getIsActive())
                .betweenIfPresent(PromotionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(PromotionDO::getId));
    } 

}
